package com.shuai.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.shuai.stickynote.MoreMenuItem;
import com.shuai.stickynote.R;

import java.util.ArrayList;

public class MoreMenuAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<MoreMenuItem> data;

    public MoreMenuAdapter(Context context, ArrayList<MoreMenuItem> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.more_menu_item,null);
        ImageView v_icon = convertView.findViewById(R.id.more_menu_icon);
        TextView v_name = convertView.findViewById(R.id.more_menu_name);
        v_icon.setImageResource(data.get(position).getIcon());
        v_name.setText(data.get(position).getName());
        return convertView;
    }
}
